package androidx.appcompat.widget;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.view.ActionMode.Callback;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.widget.TextView;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.core.widget.TextViewCompat;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import o.ca;
import o.cc;
import o.cf;
import o.ct;
import o.gv;
import o.gv.a;
import o.hy;
import o.is;

public class AppCompatTextView extends TextView implements hy, is {
    private final cc ˊ;
    private final ca ˎ;
    @Nullable
    private Future<gv> ˏ;

    public AppCompatTextView(Context context) {
        this(context, null);
    }

    public AppCompatTextView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 16842884);
    }

    public AppCompatTextView(Context context, AttributeSet attributeSet, int i) {
        super(ct.ˋ(context), attributeSet, i);
        this.ˎ = new ca(this);
        this.ˎ.ˋ(attributeSet, i);
        this.ˊ = new cc(this);
        this.ˊ.ˏ(attributeSet, i);
        this.ˊ.ˊ();
    }

    public void setBackgroundResource(@DrawableRes int i) {
        super.setBackgroundResource(i);
        if (this.ˎ != null) {
            this.ˎ.ˎ(i);
        }
    }

    public void setBackgroundDrawable(Drawable drawable) {
        super.setBackgroundDrawable(drawable);
        if (this.ˎ != null) {
            this.ˎ.ˋ(drawable);
        }
    }

    @RestrictTo({d.ˊ})
    public void setSupportBackgroundTintList(@Nullable ColorStateList colorStateList) {
        if (this.ˎ != null) {
            this.ˎ.ˊ(colorStateList);
        }
    }

    @Nullable
    @RestrictTo({d.ˊ})
    public ColorStateList ˊ() {
        return this.ˎ != null ? this.ˎ.ˎ() : null;
    }

    @RestrictTo({d.ˊ})
    public void setSupportBackgroundTintMode(@Nullable Mode mode) {
        if (this.ˎ != null) {
            this.ˎ.ॱ(mode);
        }
    }

    @Nullable
    @RestrictTo({d.ˊ})
    public Mode ॱ() {
        return this.ˎ != null ? this.ˎ.ॱ() : null;
    }

    public void setTextAppearance(Context context, int i) {
        super.setTextAppearance(context, i);
        if (this.ˊ != null) {
            this.ˊ.ˋ(context, i);
        }
    }

    protected void drawableStateChanged() {
        super.drawableStateChanged();
        if (this.ˎ != null) {
            this.ˎ.ˋ();
        }
        if (this.ˊ != null) {
            this.ˊ.ˊ();
        }
    }

    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        super.onLayout(z, i, i2, i3, i4);
        if (this.ˊ != null) {
            this.ˊ.ˏ(z, i, i2, i3, i4);
        }
    }

    public void setTextSize(int i, float f) {
        if (ॱ) {
            super.setTextSize(i, f);
        } else if (this.ˊ != null) {
            this.ˊ.ˊ(i, f);
        }
    }

    protected void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        super.onTextChanged(charSequence, i, i2, i3);
        if (this.ˊ != null && !ॱ && this.ˊ.ˎ()) {
            this.ˊ.ˏ();
        }
    }

    @RestrictTo({d.ˊ})
    public void setAutoSizeTextTypeWithDefaults(int i) {
        if (ॱ) {
            super.setAutoSizeTextTypeWithDefaults(i);
        } else if (this.ˊ != null) {
            this.ˊ.ˋ(i);
        }
    }

    @RestrictTo({d.ˊ})
    public void setAutoSizeTextTypeUniformWithConfiguration(int i, int i2, int i3, int i4) throws IllegalArgumentException {
        if (ॱ) {
            super.setAutoSizeTextTypeUniformWithConfiguration(i, i2, i3, i4);
        } else if (this.ˊ != null) {
            this.ˊ.ॱ(i, i2, i3, i4);
        }
    }

    @RestrictTo({d.ˊ})
    public void setAutoSizeTextTypeUniformWithPresetSizes(@NonNull int[] iArr, int i) throws IllegalArgumentException {
        if (ॱ) {
            super.setAutoSizeTextTypeUniformWithPresetSizes(iArr, i);
        } else if (this.ˊ != null) {
            this.ˊ.ˎ(iArr, i);
        }
    }

    @RestrictTo({d.ˊ})
    public int getAutoSizeTextType() {
        if (!ॱ) {
            return this.ˊ != null ? this.ˊ.ˋ() : 0;
        } else {
            if (super.getAutoSizeTextType() == 1) {
                return 1;
            }
            return 0;
        }
    }

    @RestrictTo({d.ˊ})
    public int getAutoSizeStepGranularity() {
        if (ॱ) {
            return super.getAutoSizeStepGranularity();
        }
        if (this.ˊ != null) {
            return this.ˊ.ॱ();
        }
        return -1;
    }

    @RestrictTo({d.ˊ})
    public int getAutoSizeMinTextSize() {
        if (ॱ) {
            return super.getAutoSizeMinTextSize();
        }
        if (this.ˊ != null) {
            return this.ˊ.ॱॱ();
        }
        return -1;
    }

    @RestrictTo({d.ˊ})
    public int getAutoSizeMaxTextSize() {
        if (ॱ) {
            return super.getAutoSizeMaxTextSize();
        }
        if (this.ˊ != null) {
            return this.ˊ.ᐝ();
        }
        return -1;
    }

    @RestrictTo({d.ˊ})
    public int[] getAutoSizeTextAvailableSizes() {
        if (ॱ) {
            return super.getAutoSizeTextAvailableSizes();
        }
        if (this.ˊ != null) {
            return this.ˊ.ʻ();
        }
        return new int[0];
    }

    public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
        return cf.ˊ(super.onCreateInputConnection(editorInfo), editorInfo, this);
    }

    public void setFirstBaselineToTopHeight(@Px @IntRange(from = 0) int i) {
        if (VERSION.SDK_INT >= 28) {
            super.setFirstBaselineToTopHeight(i);
        } else {
            TextViewCompat.ˋ(this, i);
        }
    }

    public void setLastBaselineToBottomHeight(@Px @IntRange(from = 0) int i) {
        if (VERSION.SDK_INT >= 28) {
            super.setLastBaselineToBottomHeight(i);
        } else {
            TextViewCompat.ॱ((TextView) this, i);
        }
    }

    public int getFirstBaselineToTopHeight() {
        return TextViewCompat.ॱ((TextView) this);
    }

    public int getLastBaselineToBottomHeight() {
        return TextViewCompat.ˋ((TextView) this);
    }

    public void setLineHeight(@Px @IntRange(from = 0) int i) {
        TextViewCompat.ˏ((TextView) this, i);
    }

    public void setCustomSelectionActionModeCallback(Callback callback) {
        super.setCustomSelectionActionModeCallback(TextViewCompat.ˏ((TextView) this, callback));
    }

    public void setTextMetricsParamsCompat(@NonNull a aVar) {
        TextViewCompat.ˎ((TextView) this, aVar);
    }

    public void setPrecomputedText(@NonNull gv gvVar) {
        TextViewCompat.ˎ((TextView) this, gvVar);
    }

    private void ˎ() {
        if (this.ˏ != null) {
            try {
                Future future = this.ˏ;
                this.ˏ = null;
                TextViewCompat.ˎ((TextView) this, (gv) future.get());
            } catch (InterruptedException e) {
            } catch (ExecutionException e2) {
            }
        }
    }

    public CharSequence getText() {
        ˎ();
        return super.getText();
    }

    public void setTextFuture(@NonNull Future<gv> future) {
        this.ˏ = future;
        requestLayout();
    }

    protected void onMeasure(int i, int i2) {
        ˎ();
        super.onMeasure(i, i2);
    }
}
